{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Display a Web Scene Tutorial\n",
    "\n",
    "This is the completed solution for the [Diplay a web scene](https://developers.arcgis.com/labs/develop/python/display-a-web-scene) ArcGIS tutorial. \n",
    "\n",
    "[ArcGIS tutorials](https://developers.arcgis.com/labs/) are short guides demonstrating the three phases of building geospatial apps: Data, Design, Develop."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from arcgis.gis import GIS\n",
    "\n",
    "gis = GIS()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<Item title:\"3d trails and trailheads LA\" type:Web Scene owner:tim.lohnes_Hayward>,\n",
       " <Item title:\"Durango Trail Scene\" type:Web Scene owner:al_geodev>,\n",
       " <Item title:\"LA Trails and Trailheads\" type:Web Scene owner:esri_devlabs>,\n",
       " <Item title:\"LA Parks and Trails Scene (unstyled)\" type:Web Scene owner:esri_devlabs>,\n",
       " <Item title:\"LA Parks and Trails Scene (styled)\" type:Web Scene owner:esri_devlabs>,\n",
       " <Item title:\"树木\" type:Web Scene owner:wuzhongyuan>]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "webscene_search = gis.content.search(query=\"LA Trails *\", item_type=\"Web Scene\")\n",
    "webscene_search"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div class=\"item_container\" style=\"height: auto; overflow: hidden; border: 1px solid #cfcfcf; border-radius: 2px; background: #f6fafa; line-height: 1.21429em; padding: 10px;\">\n",
       "                    <div class=\"item_left\" style=\"width: 210px; float: left;\">\n",
       "                       <a href='https://www.arcgis.com/home/item.html?id=1da0ba4b0f674286875e58ec397260f1' target='_blank'>\n",
       "                        <img src='https://www.arcgis.com/sharing/rest//content/items/1da0ba4b0f674286875e58ec397260f1/info/thumbnail/thumbnail.jpeg' class=\"itemThumbnail\">\n",
       "                       </a>\n",
       "                    </div>\n",
       "\n",
       "                    <div class=\"item_right\"     style=\"float: none; width: auto; overflow: hidden;\">\n",
       "                        <a href='https://www.arcgis.com/home/item.html?id=1da0ba4b0f674286875e58ec397260f1' target='_blank'><b>LA Trails and Trailheads</b>\n",
       "                        </a>\n",
       "                        <br/><img src='https://www.arcgis.com/home/js/jsapi/esri/css/images/item_type_icons/websceneglobal16.png' style=\"vertical-align:middle;\">Web Scene by esri_devlabs\n",
       "                        <br/>Last Modified: July 16, 2018\n",
       "                        <br/>0 comments, 1,290 views\n",
       "                    </div>\n",
       "                </div>\n",
       "                "
      ],
      "text/plain": [
       "<Item title:\"LA Trails and Trailheads\" type:Web Scene owner:esri_devlabs>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "webscene_item = webscene_search[2]\n",
    "webscene_item"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## To display a web scene in your notebook, query the `WebScene` object."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "92298271d770412bbb55a3c305aeacdc",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "MapView(hide_mode_switch=True, layout=Layout(height='400px', width='100%'), mode='3D')"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div class=\"map-static-img-preview-b1a198fb-d4b5-4244-8d4f-cf52ff29bb75\"><img src=\"\"></img></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from arcgis.map import Scene\n",
    "la_trails = Scene(item=webscene_item)\n",
    "la_trails"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Challenge"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The web scene has 2 layers\n"
     ]
    }
   ],
   "source": [
    "op_layers = la_trails.content.layers\n",
    "print(\"The web scene has {} layers\".format(len(op_layers)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Trailheads - Trailheads\n",
      "\thttps://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads/FeatureServer/0\n",
      "Trails - Trails 0\n",
      "\thttps://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails/FeatureServer/0\n"
     ]
    }
   ],
   "source": [
    "for lyr in op_layers:\n",
    "    print(\"{}\\n\\t{}\".format(lyr['title'], lyr['url']))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "esriNotebookRuntime": {
   "notebookRuntimeName": "ArcGIS Notebook Python 3 Standard",
   "notebookRuntimeVersion": "9.0"
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
